package main

func scoreOfParenthese(s string) int {
	sk := []int{0}
	for _,c := range s {
		if c=='('{
			sk =append(sk, 0)
		}else{
			v := sk[len(sk)-1]
			sk = sk[:len(sk)-1]
			sk[len(sk)-1] += max(2*v,1)
		}
	}
	return sk[0]
}

func max(a,b int) int {
	if a>b{return a}
	return b
}